
{% extends "configuration/left_menu.html" %}

{% block right_content %}

<div id="right_menu">

    <div class="row">
        <div class="col-md-2">
            <h3><strong>编辑配置元数据</strong></h3>
        </div>
        <div class="col-md-10">
            <div class="alert-msg"></div>
        </div>

    </div>
    <hr/>
    <div>
        <div class="form-group">
            <a href="{% url 'configuration:showAddForm' %}" id="add" class="btn btn-info hint hint-bottom" style="float:left;margin-right: 10px;" data-hint="添加一个配置元数据项" ><span class="glyphicon glyphicon-plus"></span></a>
        </div>

    </div>
    <table id="example" style="table-layout:fixed;" class="table table-bordered table-hover">
        <thead >
        <td class="col" style="width:10%">ID</td>
        <td class="col" style="width:10%">SVN 仓库路径</td>
        <td class="col" style="width:12%">manager 节点配置文件存放路径</td>
        <td class="col" style="width:12%">分类</td>
        <td class="col" style="width:10%">创建时间</td>
        <td class="col" style="width:10%">操作</td>
        </thead>
        {% if config_meta_list %}

        {% for config_meta in config_meta_list %}
        <tr>
            <!-- <td class="col">{{ equipment.equipment_no }}</td> -->
            <td class="col">{{ config_meta.id }}</td>
            <td class="col">{{ config_meta.svn_path }}</td>
            <td class="col">{{ config_meta.manage_path }}</td>
            <td class="col">{{ config_meta.category }}</td>
            <td class="col">{{ config_meta.createtime }}</td>
            <td class="col">

                 <div>
                    <a class="edit_item mouse_pointer hint hint-top" data-metaid="{{ config_meta.id }}" data-target="#editItem" data-hint="点击编辑服务器信息"><span class="glyphicon glyphicon-edit"></span></a>&nbsp;
                   
                    <a data-metaid="{{ config_meta.id }}" class="delete_item mouse_pointer hint hint-top" data-hint="点击删除次条服务器信息"><span class="glyphicon glyphicon-trash"></span></a>
                 </div>

            </td>
        </tr>
        {% endfor %}
        {% endif %}
    </table>
    
    <div class="bottom_menu">
        <span>跳转到
         <select class="pagei">
             {% for temppage in page_list %}
             <option value="{{ temppage }}" {% ifequal temppage page %}selected {% endifequal %}>{{ temppage }}</option>
             {% endfor %}
         </select>页
        </span>
        <span style="padding-left: 28%;">每页{{ page_num }}条，第{{ page }}页，共{{ count }}条，共{{ page_total }}页</span>
        <span style="float:right;padding-right:50px">

            <a class="word hint hint-top" href="{% url 'configuration:showListForm' %}?page=1" data-hint="首页"><span class="glyphicon glyphicon-fast-backward"></span></a>
            {% ifnotequal page 1 %}&nbsp;
            <a href="{% url 'configuration:showListForm' %}?page={{ page|add:-1 }}" class="hint hint-top" data-hint="点击跳转到上一页"><span class="glyphicon glyphicon-step-backward"></span></a>
            {% endifnotequal %}
            {% ifnotequal page page_total %}&nbsp;
            <a href="{% url 'configuration:showListForm' %}?page={{ page|add:1 }}" class="hint hint-top" data-hint="点击跳转到下一页"><span class="glyphicon glyphicon-step-forward"></span></a>
            {% endifnotequal %}&nbsp;
            <a class="word hint hint-top" href="{% url 'configuration:showListForm' %}?page={{ page_total }}" data-hint="尾页"><span class="glyphicon glyphicon-fast-forward"></span></a>

        </span>
    </div>
</div>

<script type="text/javascript">
    
    $(".edit_item").click(function(){

        var config_meta_id = $(this).data("metaid");
        window.location.href="{% url 'configuration:showEditForm' %}?page=" + {{ page }} + "&config_meta_id="+config_meta_id;

    });

    $(".delete_item").click(function() {
        /* Act on the event */

        if(confirm("确定要删除吗？删除操作不可恢复！")) {

            var id = $(this).data('metaid');
            var url = "{% url 'configuration:deleteConfigMeta' %}";
            var postdata = { id:id }
            var ret_data = $.ajax({
                url : url,
                type : "POST",
                data : postdata,
                async : false,
                cache : false
            });

            if(ret_data.status == 200) {

                app_res_status = ret_data.responseJSON.status;
                message = ret_data.responseJSON.message;

                if(app_res_status == 1) {
                    alert_msg('success', message);
                    setTimeout(function() {
                      window.location.reload();
                    }, 2500);
                } else {
                    alert_msg('danger', message);
                }

            } else {
                alert_msg('danger', "服务器错误!");
            }

        }
    });

</script>

{% endblock %}
